import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wanxiang_app/bean/kan_list_entity.dart';
import 'package:wanxiang_app/bean/record_list_entity.dart';
import 'package:wanxiang_app/bean/simple_entity.dart';
import 'package:wanxiang_app/pages/home/detail.dart';
import 'package:wanxiang_app/pages/home/kanjia.dart';
import 'package:wanxiang_app/pages/my/charge.dart';
import '../../utils/common.dart';
import '../../utils/constant.dart';
import '../../utils/network_manager.dart';
import '../../utils/network_url.dart';
import '../../utils/toast_util.dart';
import '../../utils/user_util.dart';
import '../../widgets/myappbar.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:get/get.dart';

import '../../widgets/simple_dialog.dart';

class PriceMyController extends GetxController{
  @override
  void onInit() {
    super.onInit();
    _getKan();
  }
  @override
  void onClose() {
    super.onClose();
  }
  int clickIndex = 0;
  List<Map> tabs=[{'name':'全部','value':''},{'name':'待支付','value':'0'},{'name':'砍价中','value':'1'},
    {'name':'卖家还价','value':'2'},
    {'name':'砍价成功','value':'3'},{'name':'砍价失败','value':'4'},
    // {'name':'砍价成功','value':'5'},{'name':'砍价失败','value':'6'},
    {'name':'已购买','value':'7'}];
  List<KanListData> list = [];
  void _getKan(){
    DioManager.getInstance().post(ServiceUrl.kanList2,{
     "user_name": UserUtil.getUSER()?.userName,
      'istatus':tabs[clickIndex]['value']
    }, (data) async {
      easyRefreshController.finishRefresh();
      KanListEntity bannerEntity = KanListEntity.fromJson(jsonDecode(data));
      list = bannerEntity.data;
      update();
    }, (error) {
      ToastUtil.show(error);
    });
  }
  late BuildContext mContext ;
  void _cancel(id){
    showDialog(context: mContext, builder: (BuildContext context1) {
      return MySimpleDialog(callBack: (String content) {
        if(content == 'cancel'){
          Navigator.pop(context1);
        }else if(content == 'sure'){

          DioManager.getInstance().post(ServiceUrl.cancelKan,{
            "user_name": UserUtil.getUSER()?.userName,
            'bargaining_id':id.toString()
          }, (data) async {
            SimpleEntity bannerEntity = SimpleEntity.fromJson(jsonDecode(data));
            ToastUtil.show(bannerEntity.msg);
            _getKan();
            update();
          }, (error) {
            ToastUtil.show(error);
          });
          Navigator.pop(context1);
        }
      },
        msg: "是否确认取消砍价？",
        cancelText: '取消',
        sureText: "确认",
      );
    });
  }

  void sureKan(id){
    showDialog(context: mContext, builder: (BuildContext context1) {
      return MySimpleDialog(callBack: (String content) {
        if(content == 'cancel'){
          Navigator.pop(context1);
        }else if(content == 'sure'){

          DioManager.getInstance().post(ServiceUrl.sureKan,{
            "user_name": UserUtil.getUSER()?.userName,
            'bargaining_id':id.toString()
          }, (data) async {
            SimpleEntity bannerEntity = SimpleEntity.fromJson(jsonDecode(data));
            ToastUtil.show(bannerEntity.msg);
            _getKan();
            update();
          }, (error) {
            ToastUtil.show(error);
          });
          Navigator.pop(context1);
        }
      },
        msg: "确认该砍价？",
        cancelText: '取消',
        sureText: "确认",
      );
    });
  }


  void _again(id,KanListData item){

    Get.to(()=>KanjiaPage(),arguments:{
      "channel_id":item.channelId.toString(),
      "goods_id":item.goodsId.toString(),
      "price":item.oldPrice.toString(),
      "kan_id":id.toString(),
    },preventDuplicates:false )?.then((value) =>_getKan() );

    // showDialog(context: mContext, builder: (BuildContext context1) {
    //   return MySimpleDialog(callBack: (String content) {
    //     if(content == 'cancel'){
    //       Navigator.pop(context1);
    //     }else if(content == 'sure'){
    //       DioManager.getInstance().post(ServiceUrl.cancelKan,{
    //         "user_name": UserUtil.getUSER()?.userName,
    //         'bargaining_id':id.toString()
    //       }, (data) async {
    //         SimpleEntity bannerEntity = SimpleEntity.fromJson(jsonDecode(data));
    //         ToastUtil.show(bannerEntity.msg);
    //         _getKan();
    //         Get.to(()=>KanjiaPage(),arguments:{
    //           "channel_id":item.channelId.toString(),
    //           "goods_id":item.goodsId.toString(),
    //           "price":item.oldPrice.toString(),
    //         },preventDuplicates:false );
    //         update();
    //       }, (error) {
    //         ToastUtil.show(error);
    //       });
    //       Navigator.pop(context1);
    //     }
    //   },
    //     msg: "是否取消本订单，并再次报价？",
    //     cancelText: '取消',
    //     sureText: "确认",
    //   );
    // });
  }
  EasyRefreshController easyRefreshController = EasyRefreshController(
    controlFinishRefresh: true,
    controlFinishLoad: true,
  );
  var baopeiRate = 0.1.obs;

  _getRealPrice(KanListData item){
    if(item.offerPrice.isNotEmpty){
      return item.offerPrice;
    }
    if(item.newPrice.isNotEmpty){
      return item.newPrice;
    }
    return item.oldPrice;
  }

  _getBPFee(KanListData item){
    // double.parse(item.realityPrice)+20}元，包赔费用${().toStringAsFixed(2)
  double aa = (double.parse(item.realityPrice)+20) *baopeiRate.value;
  if(baopeiRate.value==0.1){
    if(aa<50){
      return 50;
    }
    return aa;
  }else {
    if(aa<100){
      return 100;
    }
    return aa;
  }


  }


}

class PriceMyPage extends   GetView<PriceMyController>  {

late PriceMyController controller ;
late BuildContext context ;
@override
Widget build(BuildContext context1) {
  Get.lazyPut<PriceMyController>(() => PriceMyController());
  controller = Get.find();
  context = context1;
  controller.mContext= context1;
  return GetBuilder<PriceMyController>(
    builder: (_){
      return  Scaffold(
          appBar: MyAppBar(context: context, title:'我的砍价',hasLeading: true,),
          backgroundColor: Colors.white,
          body:_content());
    },
  );
}

List<Widget> tabsItems(){
  List<Widget> aa = [];
  for(int i =0 ;i<controller.tabs.length;i++){
    aa.add(_tabItem(controller.tabs[i]['name'],i));
  }
  return aa;
}

Widget _tabItem(name,index){
  return InkWell(
    onTap: (){
      controller.clickIndex = index;
      controller._getKan();
      controller.update();
    },
    child: Container(
      margin: EdgeInsets.only(right: 10.w),
      child:  Column(
        children: [
          Text(name,style: TextStyle(color:Color(0xFF333333),fontSize: 14.sp),),
          SizedBox(height: 10.h,),
          controller.clickIndex == index?
          Container(
            width: 27.w,
            height: 2.h,
            color: Color(0xFF007BE5),
          ):Container(   height: 2.h,)
        ],
      )
    )
  ) ;
}

Widget _content(){
  return
      Container(
        width: Get.width,
        child: Column(
          children: [

            Container(
                margin: EdgeInsets.only(top: 10.h),
                padding: EdgeInsets.only(left: 10.w,right: 10.w),
                child:
                SingleChildScrollView(
                  scrollDirection:Axis.horizontal,
                  child: Row(
                    children: tabsItems(),
                  ),
                )

            )
            ,
            controller.list.length==0?Container():Container(height: 8.h,color: Color(0xFFF7F8FC),),
            controller.list.length==0?_empty():
            Container(
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height - 8.h - 120.h,
              child: _refresh(),
            )
          ],
        )
      )
;
}


  Widget _refresh(){
    return   Scaffold(
        backgroundColor: Colors.white,
        body:  EasyRefresh(
          header: ClassicHeader(
            dragText: 'Pull to refresh'.tr,
            armedText: 'Release ready'.tr,
            readyText: 'Refreshing...'.tr,
            processingText: 'Refreshing...'.tr,
            processedText: 'Succeeded'.tr,
            noMoreText: 'No more'.tr,
            failedText: 'Failed'.tr,
            messageText: 'Last updated at %T'.tr,
          ),
          footer: ClassicFooter(
            dragText: 'Pull to load'.tr,
            armedText: 'Release ready'.tr,
            readyText: 'Loading...'.tr,
            processingText: 'Loading...'.tr,
            processedText: 'Succeeded'.tr,
            noMoreText: 'No more'.tr,
            failedText: 'Failed'.tr,
            messageText: 'Last updated at %T'.tr,
          ),
          controller: controller.easyRefreshController,
          onRefresh: () async {
            controller._getKan();
          },
          onLoad: () async {
            controller.easyRefreshController.finishLoad(
                IndicatorResult.noMore );
          },
          child: ListView.separated(
            itemBuilder: (context, index) {
              return _gameItems(controller.list[index]);
            }, separatorBuilder: (BuildContext context, int index) {
            return Container(height: 8.h,color: Color(0xFFF7F8FC),);
          }, itemCount: controller.list.length,
          ),
        ));
  }

Widget _empty(){
  return Container(
    margin: EdgeInsets.only(top: 50.h),
    alignment: Alignment.center,
    child: Image.asset(Constant.IMG_BASE+'empty.png',width: 150.w,height: 127.h,),
  );
}

  Widget _gameItems(KanListData item){
    return
      InkWell(
          onTap: (){
            Get.to(()=>DetailPage(),arguments: {
              "title":item.title,
              "record_id":item.channelId.toString(),
              "channel_name":'',
              "goods_id":item.goodsId.toString(),
            },preventDuplicates:false);
          },
          child: Container(
            margin: EdgeInsets.only(left: 16.w,right: 13.w,top: 12.h),
            child:
            Column(
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('订单号：${item.id}',style: TextStyle(
                        color: Color(0xFF333333),
                        fontWeight: FontWeight.bold,
                        fontSize: 12.sp
                    ),),

                    Text(Common.kanStatusToText(item.isIstatus),style: TextStyle(
                        color: Color(0xFF007BE5),
                        fontSize: 12.sp
                    ),),
                  ],
                ),
                Container(
                  margin: EdgeInsets.only(top: 10.h,bottom: 10.h),
                  height: 1.h,
                  color: Color(0xFFF3F3F3),
                ),
                Row(
                  children: [
                    Container(
                        width: 100.w,
                        height: 78.h,
                        child: Stack(
                          children: [
                            _officer(),
                            ClipRRect(
                                borderRadius: BorderRadius.circular(10.r),
                              child: Image.network(Common.realPicPath(item.imgUrl,),width: 100.w,height: 78.h,fit: BoxFit.cover,)
                            )
                          ],
                        )

                    ),
                    SizedBox(width: 14.w,),
                    Container(
                        width: MediaQuery.of(context).size.width - 29.w - 14.w - 100.w,
                        child:  Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(item.title,
                              style: TextStyle(color: Color(0xFF333333),fontSize: 14.sp,),maxLines: 1,    textAlign: TextAlign.left,
                              overflow: TextOverflow.ellipsis,),
                            SizedBox(height: 10.h,),
                            Text('区服：${item.categoryText}',style: TextStyle(color: Color(0xFF666666),fontSize: 13.sp),),
                            SizedBox(height: 6.h,),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                item.isMsg==1?
                                _second():Container(),
                              ],
                            ),

                          ],
                        )
                    ),

                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    Row(
                      children: [
                        Text('原价：',style: TextStyle(color: Color(0xFF999999),fontSize: 12.sp),),
                        Text('¥',style: TextStyle(color: Color(0xFF999999),fontSize: 12.sp),),
                        Text(item.oldPrice,style: TextStyle(color: Color(0xFF666666),fontSize: 18.sp),),
                      ],
                    ),

                    SizedBox(width: 10.w,),
                    Row(
                      children: [
                        Text('报价：',style: TextStyle(color: Color(0xFF999999),fontSize: 12.sp),),
                        Text('¥',style: TextStyle(color: Color(0xFFFF0000),fontSize: 12.sp),),
                        Text(item.newPrice,style: TextStyle(color: Color(0xFFFF0000),fontSize: 18.sp),),
                      ],
                    ),
                    SizedBox(width: 10.w,),
                    Row(
                      children: [
                        item.offerPrice.isEmpty || double.parse(item.offerPrice)==0 ?Container():
                        Container(
                          child: Row(
                            children: [
                              SizedBox(width: 10.w,),
                              Text('还价：',style: TextStyle(color: Color(0xFF999999),fontSize: 12.sp),),
                              Text('¥',style: TextStyle(color: Color(0xFFFF0000),fontSize: 12.sp),),
                              Text(item.offerPrice,style: TextStyle(color: Color(0xFFFF0000),fontSize: 18.sp),),
                            ],
                          ),
                        )
                      ],
                    )

                  ],
                ),
                SizedBox(height: 13.h,),
                // _info(),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text( Common.transferDate(item.bargainingTime),style: TextStyle(color: Color(0xFF999999),fontSize: 12.sp),),
                    _btns(item.isIstatus,item)
                  ],
                ),
                SizedBox(height: 13.h,),

              ],
            )
            ,
          )
      )
    ;
  }

  Widget _second(){
    return Container(
      width: 55.w,
      height: 24.h,
      alignment: Alignment.center,
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(4.r),
          border: Border.all(width: 1.w,color: Color(0xFF4EBCFF))
      ),
      child: Text('可二次',style: TextStyle(
          color: Color(0xFF4EBCFF),
          fontSize: 12.sp
      ),),
    );
  }

  Widget _officer() {
    return Container(
      child: Image.asset(Constant.IMG_BASE+'baopei.png',width: 52.w,height: 17.h,fit: BoxFit.fitWidth,),
    );
  }

  Widget _info(){
    return Container(
      color: Color(0xFFFBFBFB),
      padding: EdgeInsets.all(10.w),
      child: Column(
        children: [
          Row(
            children: [
              Flexible(
                  flex:1,
                  child:   Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Row(
                        children: [
                          Text('状态:',style: TextStyle(
                              color: Color(0xFF666666),
                              fontSize: 13.sp
                          ),),
                          Text('在售',style: TextStyle(
                              color: Color(0xFFFF9100),
                              fontSize: 13.sp
                          ),)
                        ],
                      ),


                    ],
                  )),
              Flexible(
                flex: 1,
                child:  Text('上架：2023.05.10  10:30',style: TextStyle(
                    color: Color(0xFF666666),
                    fontSize: 13.sp
                ),),
              ),
            ],
          ),
          SizedBox(height: 7.h,),
          Row(
            children: [
              Expanded(
                flex: 1,
                child:  Text('商品类型:官方',style: TextStyle(
                    color: Color(0xFF666666),
                    fontSize: 13.sp
                ),),
              ),

              Expanded(
                flex: 1,
                child:  Text('营地号:asasasasa',style: TextStyle(
                    color: Color(0xFF666666),
                    fontSize: 13.sp
                ),),
              ),
            ],
          ),
          SizedBox(height: 7.h,),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text('商品编号：111111111111111111111111',style: TextStyle(
                  color: Color(0xFF666666),
                  fontSize: 13.sp
              ),),

            ],
          ),
        ],
      ),
    );
  }

  Widget _btns(status,KanListData item){
  if(status == 0){
    return _btnWait(item);
  }
  if(status == 1){
    return _btnIng(item);
  }
  if(status == 2|| status==8){
    return _btnIng2(item);
  }
  if((status == 3 || status==5) && item.realityPrice.isNotEmpty){
    return _btnPay(item);
  }

    return Container();
  }

  Widget _btnWait(KanListData item){
    return Row(
      children: [
        InkWell(
          onTap: (){
            controller._cancel(item.id.toString());
          },
          child: Container(
              padding: EdgeInsets.fromLTRB(16.w, 5.h, 16.w, 5.h),
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color:  Colors.white,
                border: Border.all(color: Color(0xFFC7C7C7),width: 1),
                borderRadius: BorderRadius.all(Radius.circular(20.r)),
              ),
              child: Text(
                '取消砍价',style: TextStyle(
                  fontSize: 12.sp,
                  color: Color(0xFFC7C7C7)
              ),
              )
          )
        )
  ,
        SizedBox(width: 5.w,),
        InkWell(
          onTap: (){
            Get.to(()=>ChargePage(),arguments: {
              'channel_id':item.channelId.toString(),
            'bargaining_id':item.id.toString(),
              'new_price':item.newPrice.toString(),
            'goods_id':item.goodsId.toString(),
            'price' :(double.parse(item.newPrice)*0.05).toStringAsFixed(2).toString(),
              'readOnly':true,
              'from' :'kanjia',
            },preventDuplicates:false)?.then((value) => {
              controller._getKan()
            });
          },
          child:  Container(
              padding: EdgeInsets.fromLTRB(16.w, 5.h, 16.w, 5.h),
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color:  Colors.white,
                border: Border.all(color: Color(0xFFC7C7C7),width: 1),
                borderRadius: BorderRadius.all(Radius.circular(20.r)),
              ),
              child: Text(
                '支付押金',style: TextStyle(
                  fontSize: 12.sp,
                  color: Color(0xFFC7C7C7)
              ),
              )
          )
        )
     ,
      ],
    );
  }

Widget _btnIng(item){
  return Row(
    children: [
      InkWell(
        onTap: (){
          controller._cancel(item.id.toString());
        },
        child:  Container(
            padding: EdgeInsets.fromLTRB(16.w, 5.h, 16.w, 5.h),
            alignment: Alignment.center,
            decoration: BoxDecoration(
              border: Border.all(color: Color(0xFFC7C7C7),width: 1),
              borderRadius: BorderRadius.all(Radius.circular(20.r)),
            ),
            child: Text(
              '取消砍价',style: TextStyle(
                fontSize: 13.sp,
                color: Color(0xFFC7C7C7)
            ),
            )
        )
      )
     ,

    ],
  );
}


Widget _btnIng2(KanListData item){
  return Row(
    children: [
      InkWell(
        onTap: (){
          controller._again(item.id.toString(), item);
        },
        child: Container(
            padding: EdgeInsets.fromLTRB(8.w, 5.h, 8.w, 5.h),
            alignment: Alignment.center,
            decoration: BoxDecoration(
              border: Border.all(color: Color(0xFFC7C7C7),width: 1),
              borderRadius: BorderRadius.all(Radius.circular(20.r)),
            ),
            child: Text(
              '再次报价',style: TextStyle(
                fontSize: 13.sp,
                color: Color(0xFFC7C7C7)
            ),
            )
        )
      )
 ,
      SizedBox(width: 5.w,),
      InkWell(
          onTap: (){
            controller._cancel(item.id.toString());
          },
        child:  Container(
            padding: EdgeInsets.fromLTRB(16.w, 5.h, 16.w, 5.h),
            alignment: Alignment.center,
            decoration: BoxDecoration(
              border: Border.all(color: Color(0xFFC7C7C7),width: 1),
              borderRadius: BorderRadius.all(Radius.circular(20.r)),
            ),
            child: Text(
              '取消',style: TextStyle(
                fontSize: 13.sp,
                color: Color(0xFFC7C7C7)
            ),
            )
        )
      )
     ,
      SizedBox(width: 5.w,),
      InkWell(
        onTap: (){
          controller.sureKan(item.id.toString());
        },
        child: Container(
            padding: EdgeInsets.fromLTRB(16.w, 5.h, 16.w, 5.h),
            alignment: Alignment.center,
            decoration: BoxDecoration(
              border: Border.all(color: Color(0xFFC7C7C7),width: 1),
              borderRadius: BorderRadius.all(Radius.circular(20.r)),
            ),
            child: Text(
              '同意',style: TextStyle(
                fontSize: 13.sp,
                color: Color(0xFFC7C7C7)
            ),
            )
        )
      )
      ,
    ],
  );
}

Widget _btnIng3(KanListData item){
  return Row(
    children: [
      InkWell(
          onTap: (){
            controller._again(item.id.toString(), item);
          },
          child: Container(
              padding: EdgeInsets.fromLTRB(8.w, 5.h, 8.w, 5.h),
              alignment: Alignment.center,
              decoration: BoxDecoration(
                border: Border.all(color: Color(0xFFC7C7C7),width: 1),
                borderRadius: BorderRadius.all(Radius.circular(20.r)),
              ),
              child: Text(
                '再次报价',style: TextStyle(
                  fontSize: 13.sp,
                  color: Color(0xFFC7C7C7)
              ),
              )
          )
      )
      ,
      SizedBox(width: 5.w,),
      InkWell(
          onTap: (){
            controller._cancel(item.id.toString());
          },
          child:  Container(
              padding: EdgeInsets.fromLTRB(16.w, 5.h, 16.w, 5.h),
              alignment: Alignment.center,
              decoration: BoxDecoration(
                border: Border.all(color: Color(0xFFC7C7C7),width: 1),
                borderRadius: BorderRadius.all(Radius.circular(20.r)),
              ),
              child: Text(
                '拒绝',style: TextStyle(
                  fontSize: 13.sp,
                  color: Color(0xFFC7C7C7)
              ),
              )
          )
      )
      ,
      SizedBox(width: 5.w,),
      _btnPay(item)
      ,
    ],
  );
}

Future<Future<int?>> _showSingle(KanListData item) async {
  return showModalBottomSheet<int>(
      backgroundColor: Colors.transparent,
      isScrollControlled: true,
      context: context,
      builder: (BuildContext context1) {
        return AnimatedPadding(
            padding: MediaQuery.of(context1).viewInsets, // 我们可以根据这个获取需要的padding
            duration: const Duration(milliseconds: 100),
            child:  Container(
                height: 350.h,
                padding: EdgeInsets.all(16.w),
                clipBehavior: Clip.antiAlias,
                decoration: const BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(20.0),
                    topRight: Radius.circular(20.0),
                  ),
                ),
                child: Column(
                  children: [
                    Text('选择包赔类型',style: TextStyle(
                        color: Color(0xFF333333),
                        fontSize: 15.sp
                    ),),
                    SizedBox(height: 15.h,),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Row(
                          children: [
                            Image.asset( '${Constant.IMG_BASE}item_new.png',width: 24.w,height: 17.h,),
                            Text('普通包赔10%',style: TextStyle(
                                color: Color(0xFF333333),
                                fontSize: 16.sp,
                                fontWeight: FontWeight.bold
                            ),)
                          ],
                        ),
                        Obx(() => InkWell(
                          onTap: (){
                            controller.baopeiRate.value = 0.1;
                            controller.update();
                          },
                          child:
                          controller.baopeiRate.value==0.1?
                          Image.asset( '${Constant.IMG_BASE}radio_yy.png',width: 18.w,height: 18.h,): Image.asset( '${Constant.IMG_BASE}icon_protect_n.png',width: 18.w,height: 18.h,),
                        )),


                      ],
                    ),
                    SizedBox(height: 10.h,),
                    Text('在下单购买账号时额外支付号价的10% (最低50元)，购买交易完成后，账号不转手 (换绑手机视为转手) 永久享受包赔服务，如出现账号找回情况，平台核实后在七天内进行处理，优先追回账号，超过七天未追回将全额退还支付号款，并对找回人员进行起诉追责处理!',
                      style: TextStyle(
                          color: Color(0xFF666666),
                          fontSize: 13.sp
                      ),),

                    SizedBox(height: 15.h,),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Row(
                          children: [
                            Image.asset( '${Constant.IMG_BASE}item_new.png',width: 24.w,height: 17.h,),
                            Text('2.5包赔20%',style: TextStyle(
                                color: Color(0xFF333333),
                                fontSize: 16.sp,
                                fontWeight: FontWeight.bold
                            ),)
                          ],
                        ),
                        Obx(() => InkWell(
                          onTap: (){
                            controller.baopeiRate.value = 0.2;
                            controller.update();
                          },
                          child:
                          controller.baopeiRate.value==0.2?
                          Image.asset( '${Constant.IMG_BASE}radio_yy.png',width: 18.w,height: 18.h,): Image.asset( '${Constant.IMG_BASE}icon_protect_n.png',width: 18.w,height: 18.h,),
                        )),


                      ],
                    ),
                    SizedBox(height: 10.h,),
                    Text('在下单购买账号时额外支付号价的20% (最低100元)，交易完成后，账号不转手 (换绑手机视为转手) 永久享受2.5倍包赔服务，如出现账号找回情况，平台核实后在七天内进行处理，优先追回账号，超过七天未追回将全额退还支付号款，并对找回人员进行起诉追责处理!',
                      style: TextStyle(
                          color: Color(0xFF666666),
                          fontSize: 13.sp
                      ),),
                    SizedBox(height: 10.h,),
                    Container(
                      width: Get.width,
                      color: Color(0x0D000000),
                      height: 1.h,
                    ),
                    Container(
                        alignment: Alignment.center,
                        height: 53.h,
                        child:    Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Obx(() => Text('号价为${ double.parse(item.realityPrice)+20}元，包赔费用${(controller._getBPFee(item)).toStringAsFixed(2)}元',style: TextStyle(
                                color: Color(0xFFFF0000),
                                fontSize: 14.sp
                            ),))
                            ,
                            InkWell(
                                onTap: (){
                                  double aa = double.parse(item.realityPrice) +controller._getBPFee(item);
                                  Get.to(()=>ChargePage(),arguments: {
                                    "user_name":UserUtil.getUSER()?.userName,
                                    "buy_type":"3",
                                    "channel_id":item.channelId.toString(),
                                    "goods_id":item.goodsId.toString(),
                                    "price":aa.toStringAsFixed(2),
                                    "from":'buyNow',
                                    "readOnly":true,
                                    "CompensationCode":controller.baopeiRate.value==0.1?'ordinaryBP':'twoFiveBP',
                                  },preventDuplicates:false);


                                  // Get.off(()=>ChargePage(),arguments: {
                                  //   'readOnly':true,
                                  //   'price':aa.toStringAsFixed(2),
                                  //   'from':'buyNow',
                                  //   "channel_id":controller.detailData.channelId,
                                  //   "goods_id":controller.detailData.id.toString(),
                                  // });
                                },
                                child: Container(
                                  alignment: Alignment.center,
                                  width: 104.w,
                                  height: 31.h,
                                  decoration: BoxDecoration(
                                      color: Color(0xFF007BE5),
                                      borderRadius: BorderRadius.all(Radius.circular(16.r))
                                  ),
                                  child: Text('立即支付',style: TextStyle(
                                      color: Colors.white,
                                      fontSize: 13.sp
                                  ),),
                                )
                            )


                          ],
                        )
                    )

                  ],
                )
            )
        ) ;
      });
}

Widget _btnPay(KanListData item){
  return Row(
    children: [
      InkWell(
        onTap: (){
          // Get.to(()=>ChargePage(),arguments: {
          //   "user_name":UserUtil.getUSER()?.userName,
          //   "buy_type":"3",
          //   "channel_id":item.channelId.toString(),
          //   "goods_id":item.goodsId.toString(),
          //   "price":item.realityPrice,
          //   "from":'buyNow',
          //   "readOnly":false
          // },preventDuplicates:false);

          _showSingle(item);

          // controller._cancel(item.id);
        },
        child: Container(
            padding: EdgeInsets.fromLTRB(16.w, 5.h, 16.w, 5.h),
            alignment: Alignment.center,
            decoration: BoxDecoration(
              border: Border.all(color: Color(0xFFC7C7C7),width: 1),
              borderRadius: BorderRadius.all(Radius.circular(20.r)),
            ),
            child: Text(
              '立即支付',style: TextStyle(
                fontSize: 13.sp,
                color: Color(0xFFC7C7C7)
            ),
            )
        )
      )
 ,

    ],
  );
}

}